/****************************************************************
 *This file is global.h
 ****************************************************************/
#ifndef __GLOBAL_H_
#define __GLOBAL_H_

#include "include.h"

// 上位机指令和处理函数
extern pc_cmd_str pc_cmd_data[PC_COMMAND_NUM];

// 485load 函数
extern ViUInt32 	udp_load_count[MAX_FD_NUM];
extern ViChar	 	*udp_load_data_p[MAX_FD_NUM];

// 485 LOAD的请求标志和应答标志
extern ViUInt32    udp_load_flag[MAX_FD_NUM];
extern ViUInt32    ack_udp_load_flag[MAX_FD_NUM];

// 485 upload 函数
extern ViUInt32 	udp_upload_count[MAX_FD_NUM];
extern ViChar	 	*udp_upload_data_p[MAX_FD_NUM];

// 485 uplOAD的请求标志和应答标志
extern ViUInt32    udp_upload_flag[MAX_FD_NUM];
extern ViUInt32    ack_udp_upload_flag[MAX_FD_NUM];

// 高速通信的文件描述符和状态
extern unsigned int udp_socket_fd[MAX_FD_NUM];
extern unsigned int udp_socket_fd_two[MAX_FD_NUM];
extern unsigned int udp_socket_status[MAX_FD_NUM];

// 重映射AXI-LITE空间
extern int mmap_fd;
extern unsigned char *mmap_addr;

// fifo 相关变量
extern Pfifo * fifo[_422_CHANNEL_NUM];

// 互斥锁
extern pthread_mutex_t myMutex;
extern pthread_mutex_t spaceMutex;

// 存储指令握手的变量
extern unsigned char command_buf[COMMAND_LEN][CONFIG_COMMAND_NUM];
extern unsigned char ack_command_buf[COMMAND_LEN][CONFIG_COMMAND_NUM];
extern unsigned int command_buf_len[CONFIG_COMMAND_NUM];
extern unsigned char ack_command_buf_len[CONFIG_COMMAND_NUM];

// 使能配置取数握手模式
extern unsigned int command_enable_mode;

// 读取pcm的数据缓冲区和长度
extern char pcm_rd_data_buffer[PCM_RD_LEN];
extern unsigned int pcm_rd_date_length;
extern unsigned int pcm_once_read_len;

// 读取pcm的数据缓冲区和长度
extern char pcm_rd_data_buffer_two[PCM_RD_LEN];
extern unsigned int pcm_rd_date_length_two;
extern unsigned int pcm_once_read_len_two;

// PCM存储的使用的变量
extern unsigned char pcm_one_store_buff_1[PCM_STORE_BUF_LEN];
extern unsigned int  pcm_one_store_len_1;
extern unsigned char pcm_one_store_buff_2[PCM_STORE_BUF_LEN];
extern unsigned int  pcm_one_store_len_2;
extern unsigned char pcm_one_use_channel;

// pcm当前存储状态
extern unsigned char pcm_store_flag;

// PCM存储使用的文件句柄
extern int pcm_store_fd;

// PCM存储状态
extern unsigned char pcm_store_status;

// 开启启动监控标志
extern unsigned char start_system_monitor_flag;

// PCM和日志存储总空间和已使用空间
extern unsigned int pcm_all_space, pcm_use_space;
extern unsigned int log_all_space, log_use_space;

// 创建日志文件标志
extern unsigned char create_log_name_flag;

// 日志存储使用的文件句柄
extern int log_store_fd;

// 写日志sockfd
extern int sockfd_wr_log;
extern struct sockaddr_in server_addr_wr_log;

// 接收日志数据sockfd
extern int sockfd_command;
extern struct sockaddr_in server_addr_command;

// 接收系统日志数据缓存器
extern unsigned char rev_syslog_buf[REV_LOG_BUF_LEN];
extern unsigned int  rev_syslog_len;

// 存储长度
extern long long all_store_data_len;
extern long long thread_pcm_store_len;
extern long long single_store_len;
extern long long sys_log_store_len;
extern long long inter_log_time;
extern long long inter_log_wr_time;
extern long long inter_pcm_time;
extern long long inter_pcm_wr_time;


#endif

